Skip to content

[6.x] Fix field filters returning all results when filtering by 0#14747

Merged
jasonvarga merged 5 commits into
6.xfrom
fix-0-value-in-cp-filters
Jun 4, 2026
Merged

[6.x] Fix field filters returning all results when filtering by 0#14747
jasonvarga merged 5 commits into
6.xfrom
fix-0-value-in-cp-filters

Conversation

@joshuablum
Copy link
Copy Markdown
Member

On listing views filtering a field using 0 as the value returns items as no filter was being used instead of matching ones with an actual value of 0.

Example: A text or integer field like Levels containing values like 0, 1, 2, 3, filtering for 0 ignores the filter entirely and returns all entries.

Statamic\Query\Scopes\Filters\Fields\FieldtypeFilter::isComplete() does $values = array_filter($values) where array_filter() with no callback removes every falsy element including both the string '0' and integer 0. With the value stripped, isComplete() returns false and never applies the filter.

The fix is to replace array_filter() with explicit checks, so 0 and '0' are treated as actual values while actual empty filters (null, '') are skipped.

Related:

Comment thread src/Query/Scopes/Filters/Fields/FieldtypeFilter.php
joshuablum and others added 3 commits June 2, 2026 13:57
The zero value bug isn't realistically triggerable in these classes (date,
terms, and toggle don't accept 0 as a meaningful filter value), but they
override isComplete() with the same array_filter pattern so the fix is
applied for consistency.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jasonvarga jasonvarga merged commit 638b54d into 6.x Jun 4, 2026
18 checks passed
@jasonvarga jasonvarga deleted the fix-0-value-in-cp-filters branch June 4, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants